\documentclass[E:/GsjzTle/main/main.tex]{subfiles}
\begin{document}

\begin{itemize}
\item
  给定长度为 \(N\) 的序列 (\(N≤3\times10^5\)，\(0≤A_i<2^{18}\)).
\item
  问从中取 \(1,2,3,...,n\) 个数的最大异或和分别为多少
\end{itemize}

\begin{lstlisting}
#include<bits/stdc++.h>
#define rep(i , a , b) for(int i = a ; i <= b ; i ++)
using namespace std;
const int N = 3e5 + 10;
int n , x , a[N] , s[N] , ans[N];
void fwt(int *a)
{
	rep(i , 0 , 17)
	{
		for(int j = 0 ; j < (1 << 18) ; j ++)
		{
			if(((1 << i) & j) == 0)
			{
				a[j] = a[j] + a[j ^ (1 << i)];
				a[j ^ (1 << i)] = a[j] - 2 * a[j ^ (1 << i)];
			}
		}
	}
}
signed main()
{
	cin >> n;
	rep(i , 1 , n)
	{
		cin >> x;
		a[x] = 1;
	}
	fwt(a);
	s[0] = 1;
	rep(i , 1 , 19)
	{
		fwt(s);
		for(int j = 0 ; j < (1 << 18) ; j ++) s[j] *= a[j];
		fwt(s);
		for(int j = 0 ; j < (1 << 18) ; j ++) if(s[j])
		{
			s[j] = 1;
			ans[i] = j;
		}
	}
	rep(i , 20 , n) ans[i] = ans[i - 2];
	rep(i , 1 , n) cout << ans[i] << " \n"[i == n];
	return 0;
}
\end{lstlisting}

\end{document}
